<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>新品有戏后台管理</title>
    <link href="__CSS__/boot.css" rel="stylesheet">
    <link href="__STATIC__/layui/css/layui.css" rel="stylesheet">
    <script src="__JS__/jquery.js"></script>
    <script src="__JS__/layer/layer.js"></script>
    <script src="__STATIC__/layui/layui.js"></script>
    <style>
        th{
            text-align: center;
            vertical-align: middle!important;
        }
    </style>
</head>
<body>
{include file="base/header" /}
<div style="float: right; margin-top: 5px;margin-bottom: 5px" class="box-title ">
    <form class="form-inline" action="{:url('index/content/index')}" method="get">
        <input type="text" name="title" value="<?php if(isset($title)) echo $title ?>" class="form-control" id="exampleInputEmail3" >
        <input type="submit" class="btn btn-default" value="搜索"/>
        <input type="button" onclick="res()" value="全部显示" class="btn btn-default"/>
    </form>
</div>

<table class="table table-bordered" style="width: 1300px;margin: 0 auto">
    <tr>
        <th>编号</th>
        <th>产品名称</th>
        <th>产品介绍</th>
        <th>分类</th>
        <!--<th>图片</th>-->
        <th>进货价</th>
        <th>统一零售价</th>
        <th>合作模式</th>
        <th>状态</th>
        <th>邮寄地址</th>
        <th>操作</th>
    </tr>
    {foreach $res as $val}
    <tr id="del{$val.id}" style="text-align: center">
        <td>{$val.id}</td>
        <td style="width: 200px">{$val.pname}</td>
        <td>{$val.introduce|substr=###,0,10}</td>
        <td>{$val.category}</td>
        <!--<td>{$val.image|substr=###,0,10}</td>-->
        <td>{$val.purchaseprice}元</td>
        <td>{$val.retailprice}元</td>
        <td>{if $val.cooperation == 1} 进货价采购 {else/} 少量货物月结 {/if}</td>
        <!--<td>{if $val.status == 1} 审核通过 {elseif $val.status == 3 /} 审核中 {elseif $val.status == 4/} 未审核 {else/}未通过{/if}</td>-->
        <td>{if $val.status == 6} 内容制作中 {/if}</td>
        <td style="width: 200px">{$val.customer}</td>
        <td>
            <!--<button onclick="del({$val.id})" type="button" class="btn btn-danger btn-xs">删除</button>-->
            <button onclick="picture({$val.id})" type="button" class="btn btn-primary btn-xs" >查看图片</button>
            <button onclick="shel({$val.id})" type="button" class="btn btn-success btn-xs" >上架</button>
            <button onclick="code({$val.id},{$val.bid})" type="button" class="btn btn-info btn-xs" >上传二维码</button>
            <button onclick="video({$val.id},{$val.bid})" type="button" class="btn btn-info btn-xs" >上传视频</button>
        </td>
    </tr>
    {/foreach}
</table>
<div style="margin-left: 30px">{$res->render()}</div>

</body>
<script>
    //查看图片
    function picture(id) {
        window.location.href = "{:url('index/examine/image')}?id="+id;
    }
    //删除
    function del(id) {
        layer.confirm('你确定要删除吗',{bnt:['确定','取消']},
            function () {
                $.ajax({
                    url:"{:url('index/product/delete')}",
                    type:"post",
                    data:"id="+id,
                    datatype:"json",
                    success:function (data) {
                        if(data.success){
                            layer.alert(data.success);
                            $("#del"+id).remove();
                        }else{
                            layer.alert(data.error);
                        }
                    }
                });
            }
        );
    }
    //显示所有
    function res() {
        window.location.href = "{:url('index/content/index')}";
    }
    //上架
    function shel(id) {
        $.ajax({
            url:"{:url('index/product/shel')}",
            type:"post",
            data:"id="+id,
            datatype:"json",
            success:function (data) {
                if(data.success){
                    layer.alert(data.success);
                    $("#del"+id).remove();
                }else{
                    layer.alert(data.error);
                }
            }
        });
    }
    //上传二维码
    function code(id,bid) {
        layer.open({
            type:2,
            title:"请上传二维码",
            anim:2,
            //maxmin:true,
            content:"{:url('index/content/code')}?id="+id+"&bid="+bid
        });
    }
    //上传视频
    function video(id,bid) {
        layer.open({
            type:2,
            title:"请上传视频",
            anim:2,
            content:"{:url('index/content/video')}?id="+id+"&bid="+bid
        });
    }
</script>
</html>